/*
 * @Author: 张家亮 1690608011@qq.com
 * @Date: 2022-08-18 23:11:11
 * @LastEditors: 张家亮 1690608011@qq.com
 * @LastEditTime: 2022-08-20 10:58:09
 * @FilePath: \vue-store-server\app\middleware\isLogin.js
 * @Description: 全局登录拦截器
 * 
 * Copyright (c) 2022 by 张家亮 1690608011@qq.com, All Rights Reserved. 
 */
module.exports = async (ctx, next) => {
  if (ctx.url.startsWith('/user/')) {
    if (!ctx.session.user) {
      ctx.body = {
        code: '401',
        msg: '用户没有登录，请登录后再操作'
      }
      return;
    }
  }
  await next();
}